#!/usr/bin/python3
# 文件名：server.py

# 导入 socket、sys 模块
import socket
import sys
import time

servicesocket=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
servicesocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
host=socket.gethostname()
port=9999
servicesocket.bind((host,port))
servicesocket.listen(5)
ClientSock,addr=servicesocket.accept()
while True:
    buf = ClientSock.recv(1024)
    if len(buf):
        print(time.asctime(time.localtime(time.time())))
        print ("客户端说:" + str(buf,'utf-8'))
        print("          ")
    print(time.asctime(time.localtime(time.time())))
    data = input("服务端说:")
    print("          ")
    ClientSock.sendall(data.encode('utf-8'))
    






    
